<?php
namespace app\controllers\api\account;

use fate\http\Request;
use app\models\User;
use app\libs\LibUser;
use app\libs\Util;

class EditbaseController extends \app\controllers\ForceLoginPure {
    public function run() {
        $req = Request::getInstance();

        $uid = LibUser::getLoginUid();
        $gender = $req->getParameter('gender');
        $short_intro = Util::plainText($req->getParameter('short_intro'));
        $birthday = Util::plainText($req->getParameter('birthday'));

        if(!is_numeric($gender) || !is_numeric($birthday)) {
            $this->ajaxReturn(null, 300002);
            exit;
        }

        $ret = [
            'gender' => $gender,
            'short_intro' => $short_intro,
            'birthday' => $birthday
        ];

        $user = new User();
        $ret = $user->update($uid, $ret);

        $this->ajaxReturn(null);
    }
}
